Skip to content

add global uistate fallback to allow scripting in non uistates#967

Open
TheZoroForce240 wants to merge 1 commit intoCodenameCrew:mainfrom
TheZoroForce240:ui-state-test
Open

add global uistate fallback to allow scripting in non uistates#967
TheZoroForce240 wants to merge 1 commit intoCodenameCrew:mainfrom
TheZoroForce240:ui-state-test

Conversation

@TheZoroForce240
Copy link
Copy Markdown
Contributor

workaround for the crashes you would normally get trying to use cne ui in non uistates

example of how to use:

import funkin.editors.ui.UIState;
import funkin.editors.ui.UITextBox;

var uiState:UIState;
var uiCamera:FlxCamera;

function create() {
	uiState = new UIState();
	UIState.fallbackState = uiState;
	uiState.create();

	uiCamera = new FlxCamera();
	uiCamera.bgColor = 0;
	FlxG.cameras.add(uiCamera, false);

	//add ui stuff here
	textbox = new UITextBox(100, 100, "text box");
	textbox.cameras = [uiCamera];
	uiState.add(textbox);
}

function destroy() {
	uiState.destroy();
	uiState = null;
	UIState.fallbackState = null;
}

function postUpdate(elapsed) {
	uiState.tryUpdate(elapsed);
	if (PlayState.instance != null) {
		canPause = uiState.currentFocus != null ? !(uiState.currentFocus is UITextBox) : true;
	}
}

function postDraw(elapsed) {
	uiState.draw();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant